package day13.KeJian;

import day13.XuLHL.Student;

import java.io.FileInputStream;
import java.io.IOException;
import java.io.ObjectInputStream;

public class ObjectInputStreamDemo {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
        //ObjectInputStream(InputStream in)：创建从指定的InputStream读取的ObjectInputStream
        ObjectInputStream os = new ObjectInputStream(new FileInputStream("D://itheima//nb.txt"));

        //Object readObject()：从ObjectInputStream读取一个对象
        Object obj = os.readObject();
        Student s = (Student) obj;
        System.out.println(s.getName()+","+s.getAge());
        os.close();
    }
}
